﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace DemoWebapi01.Migrations
{
    /// <inheritdoc />
    public partial class QuestionOption : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "QuestionOption",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "问题内容"),
                    ContentCN = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "问题内容(中文)"),
                    IsCorrect = table.Column<bool>(type: "bit", nullable: false, defaultValue: false, comment: "是否正确答案"),
                    QuestionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    CreatedOn = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETDATE()", comment: "创建时间"),
                    ModifiedOn = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "修改时间"),
                    LastModifiedBy = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "最后修改人"),
                    IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false, comment: "是否删除"),
                    DeletedOn = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "删除时间"),
                    DeletedBy = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "删除人"),
                    Version = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true, comment: "版本号")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_QuestionOption", x => x.Id);
                    table.ForeignKey(
                        name: "FK_QuestionOption_Question",
                        column: x => x.QuestionId,
                        principalTable: "Questions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_QuestionOption_CreatedOn",
                table: "QuestionOption",
                column: "CreatedOn");

            migrationBuilder.CreateIndex(
                name: "IX_QuestionOption_IsDeleted",
                table: "QuestionOption",
                column: "IsDeleted");

            migrationBuilder.CreateIndex(
                name: "IX_QuestionOption_QuestionId",
                table: "QuestionOption",
                column: "QuestionId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "QuestionOption");
        }
    }
}
